﻿define([], function(){
    var tpl = {};
    tpl.init1= function(){
        var html = '';
        html += basic();
        return html;
    };
    tpl.init2= function(){
        var html = '';
        html += stageTab();
        return html;
    };
    tpl.init3= function(){
        var html = '';
        html += bsid();
        return html;
    };
    tpl.init3= function(){
        var html = '';
        html += bsid();
        return html;
    };
    tpl.init4 = function(){
        var html = '';
        html += behavior();
        return html;
    };
    tpl.init5 = function(){
        var html = '';
        html += node();
        return html;
    };
    tpl.init6 = function(){
        var html = '';
        html += bsidInfo3();
        return html;
    };
    tpl.init7 = function(){
        var html = '';
        html += subtests();
        return html;
    };
    tpl.init8 = function(){
        var html = '';
        html += history();
        return html;
    };
    tpl.init9 = function(){
        var html = '';
        html += guide();
        return html;
    }; 
    tpl.init10 = function(){
        var html = '';
        html += selectTab();
        return html;
    };

    tpl.dialog = function(){
        var html = '';
        html += dialog();
        return html;
    };
    /*
    * 评估问卷模板
    * */
    var basic = function(){
        return '<script type = "text/html" id="basic-tpl">'+
                    '<li>姓名：{{userName}}</li>'+
                    '<li>{{if isPremature == 1}}实际月龄{{else if isPremature == 2}}纠正月龄{{/if}}：<span class = "actualMonthlyAge">{{monthAge}}</span></li>'+
                    '<li>测试日期 <span class = "checkDate">{{testDate}}</span></li>'+
                    '<li>照看机构：<textarea name="careAgency" id="careAgency" class="form-control" rows="1" {{if careAgency}} disabled {{/if}}>{{careAgency}}</textarea></li>'+
                    '<li>测试原因：<textarea name="testReason" id="testReason" class="form-control" rows="1" {{if reason}} disabled {{/if}}>{{reason}}</textarea></li>'+
                '</script>'
    };
    var stageTab = function(){
        return '<script type = "text/html" id="stageTab-tpl">'+
                    '<div class="prev {{if prev == 0 }}forbidden{{else}}usable{{/if}}" group = "prev" index = "{{prev}}" quesType = "{{quesType}}">'+
                        '<i class="fa fa-caret-left" aria-hidden="true"></i>'+
                    '</div>'+
                    '<div class="clearfix stages stage-labels">'+
                    '{{each data as value}}'+
                    '<div class="stage stage-label {{if !value.showFlag}}hide{{/if}} {{if value.status == 3 }} done {{else if value.status == 1}} transition {{/if}} {{if value.defaultFlag == true }}selected{{/if}}" stageId = "{{value.id}}" quesType="{{value.quesType}}" stage = {{value.stage}} initId = "{{value.initId}}" endId = "{{value.endId}}" length = "{{value.length}}">'+
                        '<div>{{value.stage}}</div>'+
                        '<div>{{value.range}}</div>'+
                    '</div>'+
                    '{{/each}}'+
                    '</div>'+
                    '<div class="next {{if next >= length }}forbidden{{else}}usable{{/if}}" group = "next"  index = "{{next}}" quesType = "{{quesType}}">'+
                        '<i class="fa fa-caret-right" aria-hidden="true"></i>'+
                    '</div>'+
                '</script>'
    };
    var bsid = function(){
        return '<script type = "text/html" id="bsid-tpl">'+
                '<div class="clearfix main-question">'+
                    '{{each data as value}}'+
                    '<div class = "item {{if value.score >= 0}}ans{{/if}} {{if value.bgFlag}}bg-0{{/if}}">'+
                        '<div class="item-details">'+
                            '<div class="item-title">{{value.name}}</div>'+
                            '<div class="item-content">{{value.desc}}</div>'+
                            '{{if value.series_ref}}'+
                            '<div class="item-series">{{value.series_name}}</div>'+
                            '{{/if}}'+
                            '<div class="cleaxfix item-scores" id = "{{value.id}}">'+
                                '<div score = "1" quesType="{{value.type}}" stage = "{{value.stageName}}" series = "{{value.series_ref}}">1分</div>'+
                                '<div score = "0" quesType="{{value.type}}" stage = "{{value.stageName}}" series = "{{value.series_ref}}">0分</div>'+
                            '</div>'+
                        '</div>'+
                        '<div class="item-mask {{if value.score >= 0}}{{if value.score == 0 }}score-0 {{else}}score-1{{/if}} {{else}} hide {{/if}}" maskId = "{{value.id}}" stage = "{{value.stageName}}">'+
                            '<div>{{value.name}}</div>'+
                            '<div class="item-status"><i class="{{if value.score == 0 }}fa fa-minus-circle{{else}}fa fa-check-circle{{/if}}" aria-hidden="true"></i></div>'+
                        '</div>'+
                    '</div>'+
                    '{{/each}}'+
                '</div>'+
                '</script>'
    };
    var behavior = function(){
        return '<script type = "text/html" id="behavior-tpl">'+
                    '<div class="behavior-observation">'+
                        '<table class="table table-bordered">'+
                            '<thead>'+
                                '<tr>'+
                                    '<th>测试者评定</th><th>题目</th><th>照样人评定</th>'+
                                '</tr>'+
                            '</thead>'+
                            '<tbody>'+
                                '<tr>'+
                                    '<td>'+
                                        '{{each evaluation as value}}'+
                                        '<div>{{value.desc}}</div>'+
                                        '{{/each}}'+
                                    '</td>'+
                                    '<td>'+
                                        '<div id="backTo" history = "{{history}}">'+
                                            '<i class="fa fa-arrow-circle-left" aria-hidden="true"></i>&nbsp;返回上一步'+
                                        '</div>'+
                                    '</td>'+
                                    '<td>'+
                                        '{{each dependant as value}}'+
                                        '<div>{{value.desc}}</div>'+
                                        '{{/each}}'+
                                    '</td>'+
                                '</tr>'+
                                '{{each questions as value}}'+
                                '<tr class="yes">'+
                                    '<td {{if value.b}} end = "end"{{/if}}>'+
                                        '<div behavior = "b.{{value.id}}-1" beId = "{{value.id}}" {{if value.b <=3 && value.b != 1 }} class = "bg-grey" {{/if}}>'+
                                            '{{if value.b == 1}}'+
                                            '<i class="fa fa-check-circle" aria-hidden="true"></i>'+
                                            '{{else}}'+
                                            '<i class="fa fa-circle-thin" aria-hidden="true"></i>'+
                                            '{{/if}}'+
                                        '</div>'+
                                        '<div behavior = "b.{{value.id}}-2" beId = "{{value.id}}" {{if value.b <=3 && value.b != 2}} class = "bg-grey" {{/if}}>'+
                                            '{{if value.b == 2}}'+
                                            '<i class="fa fa-check-circle" aria-hidden="true"></i>'+
                                            '{{else}}'+
                                            '<i class="fa fa-circle-thin" aria-hidden="true"></i>'+
                                            '{{/if}}'+
                                        '</div>'+
                                        '<div behavior = "b.{{value.id}}-3" beId = "{{value.id}}" {{if value.b <=3 && value.b != 3}} class = "bg-grey" {{/if}}>'+
                                            '{{if value.b == 3}}'+
                                            '<i class="fa fa-check-circle" aria-hidden="true"></i>'+
                                            '{{else}}'+
                                            '<i class="fa fa-circle-thin" aria-hidden="true"></i>'+
                                            '{{/if}}'+
                                        '</div>'+
                                    '</td>'+
                                    '<td>'+
                                        '<div>{{value.name}}</div>'+
                                    '</td>'+
                                    '<td {{if value.a}} end = "end"{{/if}}>'+
                                        '<div behavior = "a.{{value.id}}-1" beId = "{{value.id}}" {{if value.a <=3 && value.a != 1}} class = "bg-grey" {{/if}}>'+
                                            '{{if value.a == 1}}'+
                                            '<i class="fa fa-check-circle" aria-hidden="true"></i>'+
                                            '{{else}}'+
                                            '<i class="fa fa-circle-thin" aria-hidden="true"></i>'+
                                            '{{/if}}'+
                                        '</div>'+
                                        '<div behavior = "a.{{value.id}}-1" beId = "{{value.id}}" {{if value.a <=3 && value.a != 2}} class = "bg-grey" {{/if}}>'+
                                            '{{if value.a == 2}}'+
                                            '<i class="fa fa-check-circle" aria-hidden="true"></i>'+
                                            '{{else}}'+
                                            '<i class="fa fa-circle-thin" aria-hidden="true"></i>'+
                                            '{{/if}}'+
                                        '</div>'+
                                        '<div behavior = "a.{{value.id}}-1" beId = "{{value.id}}" {{if value.a <=3 && value.a != 3}} class = "bg-grey" {{/if}}>'+
                                            '{{if value.a == 3}}'+
                                            '<i class="fa fa-check-circle" aria-hidden="true"></i>'+
                                            '{{else}}'+
                                            '<i class="fa fa-circle-thin" aria-hidden="true"></i>'+
                                            '{{/if}}'+
                                        '</div>'+
                                    '</td>'+
                                '</tr>'+
                                '{{/each}}'+
                            '</tbody>'+
                        '</table>'+
                    '</div>'+
                '</script>'
    };
    var node = function(){
        return '<script type = "text/html" id="node-tpl">'+
                    '<div class="initialNode">'+
                        '<div>起始节点</div>'+
                        '<div>{{if start}}{{start}}{{else}}未检测到{{/if}}</div>'+
                    '</div>'+
                    '<div class="endNode">'+
                        '<div>停测</div>'+
                        '<div>{{if end}}{{end}}{{else}}未检测到{{/if}}</div>'+
                    '</div>'+
                '</script>'
    };
    var selectTab = function(){
        return '<script type = "text/html" id="selectTab-tpl">'+
                '{{each data as value,i}}'+
                    '{{if i<5}}'+
                        '<div class="stage-label item-label" quesType = "{{value.quesType}}" devAge = "{{value.devAge}}" isEnding = "{{value.isEnding}}" start = "{{value.start}}" end = "{{value.end}}">'+
                        '<div>{{value.tabName}}</div>'+
                        '<div id="{{value.quesType}}">'+
                        '{{if value.score >= 0}}'+
                        '{{value.score}}'+
                        '{{else}}'+
                            '<i class="fa fa-question-circle" aria-hidden="true"></i>'+
                        '{{/if}}'+
                        '</div>'+
                        '</div>'+
                    '{{else}}'+
                        '<div class="stage-label item-label behavior"  quesType = "{{value.quesType}}">{{value.tabName}}<br/>（选填）</div>'+
                    '{{/if}}'+
                '{{/each}}'+
            '</script>'
    }
    /*
    * 评估报告模板：
    * */
    var bsidInfo3 = function(){
        return '<script type = "text/html" id="bsidInfo3-tpl">'+
                    '<div class="info">'+
                        '<div class="basic-title">基本信息</div>'+
                        '<div class="basic-info">'+
                            '<span>孩子姓名：{{babyName}}</span>'+
                            '<span>性别：{{if gender == "N"}}男{{else}}女{{/if}}</span>'+
                            '<span>评估人：{{doctorName}}</span>'+
                            '<span>照看机构：{{if careAgency}}{{careAgency}}{{else}}-{{/if}}</span>'+
                            '<span>测试原因：{{if reason}}{{reason}}{{else}}-{{/if}}</span>'+
                        '</div>'+
                    '</div>'+
                    '<div class="age">'+
                        '<div class="basic-title">计算年龄</div>'+
                        '<div class="basic-info">'+
                            '<span>评估日期：{{testTime}}</span>'+
                            '<span>出生日期：{{birthday}}</span>'+
                            '<span>实际月龄：{{actualM}}</span>'+
                            '<span>矫正月龄：{{correctM}}</span>'+
                        '</div>'+
                        '<div class="basic-title">{{if stage}}{{stage}}{{else}}-{{/if}}</div>'+
                    '</div>'+
                '</script>'
    };
    var subtests = function(){
        return '<script type = "text/html" id="subtests-tpl">'+
                    '<table class="table table-bordered">'+
                        '<thead><tr><td></td><td>原始分</td><td>标化分</td><td>百分位</td><td>发育商</td></tr></thead>'+
                        '<tbody id = "test-score">'+
                            '<tr>'+
                                '<td class="outLine">认知（Cog）</td>'+
                                '<td>{{cogScore}}</td>'+
                                '<td>{{cogStandard}}</td>'+
                                '<td>{{cogPersent}}</td>'+
                                '<td>{{cogDiscuss}}</td>'+
                             '</tr>'+
                            '<tr><td class="outLine">语言（Lang）</td><td class="bg-fff"></td><td class="bg-fff"></td> <td class="bg-fff"></td><td class="bg-fff"></td></tr>'+
                            '<tr>'+
                                '<td>接受性交流（RC）</td>'+
                                '<td>{{RCSocre}}</td>'+
                                '<td>{{RCStandard}}</td>'+
                                '<td class="bg-fff"></td>'+
                                '<td class="bg-fff"></td>'+
                            '</tr>'+
                            '<tr>'+
                                '<td>表达性交流（EC）</td>'+
                                '<td>{{ECSocre}}</td>'+
                                '<td>{{ECStandard}}</td>'+
                                '<td></td>'+
                                '<td></td>'+
                            '</tr>'+
                            '<tr>'+
                                '<td>总</td>'+
                                '<td></td>'+
                                '<td>{{LangStandard}}</td>'+
                                '<td>{{LangPersent}}</td>'+
                                '<td>{{LangDiscuss}}</td>'+
                            '</tr>'+
                            '<tr>'+
                                '<td class="outLine">运动（Mot）</td>'+
                                '<td class="bg-fff"></td>'+
                                '<td class="bg-fff"></td>'+
                                '<td class="bg-fff"></td>'+
                                '<td class="bg-fff"></td>'+
                            '</tr>'+
                            '<tr>'+
                                '<td>精细动作（FM）</td>'+
                                '<td>{{FMSocre}}</td>'+
                                '<td>{{FMStandard}}</td>'+
                                '<td class="bg-fff"></td>'+
                                '<td class="bg-fff"></td>'+
                             '</tr>'+
                            '<tr>'+
                            '<td>大运动（GM）</td>'+
                                '<td>{{GMSocre}}</td>'+
                                '<td>{{GMStandard}}</td>'+
                                '<td class="bg-fff"></td>'+
                                '<td class="bg-fff"></td>'+
                            '</tr>'+
                            '<tr>'+
                                '<td>总</td>'+
                                '<td></td>'+
                                '<td>{{MotStandard}}</td>'+
                                '<td>{{MotPersent}}</td>'+
                                '<td>{{MotDiscuss}}</td>'+
                            '</tr>'+
                    '</tbody>'+
                '</table>'+
            '</script>'
    };
    var history = function(){
        return '<script type = "text/html" id="history-tpl">'+
                    '{{each data as value}}'+
                    '<li answerId = "{{value.answerId}}"><span class="right"></span>{{value.testTime}}({{value.testAge}})</li>'+
                    '{{/each}}'+
                '</script>'
    };
    var guide = function(){
        return '<script type = "text/html" id="guides-tpl">'+
            '{{each data as value}}'+
            '<div>'+
                '<div class="guideTitle">{{value.title}}</div>'+
                '{{each value.p as con}}'+
                '<p>{{con.con}}</p>'+
                '{{/each}}'+
            '</div>'+
            '{{/each}}'+
            '</script>'
    }
    /*
    * 弹窗模板
    * */
    var dialog = function(){
        return '<script type = "text/html" id="dialog-tpl">'+
                '<div class="modal fade" tabindex="-1" role="dialog" id="myModal">'+
                    '<div class="modal-dialog" role="document">'+
                        '<div class="modal-content">'+
                            '<div class="modal-header">'+
                                '<h4 class="modal-title">{{title}}</h4>'+
                            '</div>'+
                        '<div class="modal-body">{{tips}}</div>'+
                        '<div class="modal-footer">'+
                            '<button type="button" class="btn btn-info" data-dismiss="modal" flag = "1">{{btn1}}</button>'+
                            '<button type="button" class="btn btn-info" data-dismiss="modal" flag = "0">{{btn0}}</button>'+
                        '</div>'+
                        '</div>'+
                    '</div>'+
                '</div>'+
                '</script>'
    };
    return tpl;
});